<template>
	<view>
		<tui-skeleton v-if="skeletonShow"></tui-skeleton>
		<view class='payment-status tui-skeleton'>
			<view class='status acea-row row-center-wrapper'>
				<text class="iconfont icon-zhifuchenggong success"
					v-if="pay_status==='success'"></text>
				<text class="iconfont icon-zhifushibai fail" v-else></text>
				<text class="tui-skeleton-fillet">{{pay_status==='success' ? $t(`page.orderPayStatus.success`):$t(`page.orderPayStatus.fail`)}}</text>
			</view>
			<!-- <button class='returnBnt bg_color goOrderDetails tui-skeleton-fillet' v-if="detailShow" @click="goOrderDetails()">{{$t(`page.orderPayStatus.viewOrder`)}}</button> -->
			<button class='returnBnt cart-color tui-skeleton-fillet'
				@click="goIndex">{{$t(`page.goodsDetail.confirm`)}}</button>
		</view>
	</view>
</template>

<script>
	
	import {paypalSuccess,paypalFail,payError} from '@/api/order.js';
	import {
		mapState
	} from 'pinia'
	import {
		useAppStore
	} from '@/stores/app'

	export default {

		data() {
			return {
				skeletonShow: true,
				// success  fail
				pay_status: '',
				//  支付订单号
				trade_no: '',
				//  支付渠道
				pay_type: '',
				detailShow: true,
			};
		},
		computed: mapState(useAppStore, ['isLogin', 'userInfo']),
		onLoad: function(options) {

			this.pay_status = options.pay_status
			this.trade_no = options.trade_no
			this.pay_type = options.pay_type

			this.skeletonShow = false;
			
			// 支付失败 查找失败原因
			if (this.pay_status === 'fail') {
			  this.payErrorInfo()
			}
		},
		methods: {
			payErrorInfo() {
				payError({
			          pay_type: this.pay_type,
			          trade_no: this.trade_no
			        }).then(res => {
			        this.errorMsg = res.data
			      });
			      
			    },
			/**
			 * 去首页关闭当前所有页面
			 */
			goIndex: function(e) {
				const orderStatus = this.pay_status==='success'?1:0
				uni.redirectTo({
					url:`/pages/users/order_list/index?orderStatus=${orderStatus}`
				})
			},

		}
	}
</script>

<style lang="scss">
	.bg_color {
		@include main_bg_color(theme);
	}

	.cart_color {
		@include main_color(theme);
		@include coupons_border_color(theme);
	}

	.success {
		color: rgba(66, 202, 77, 1);
		font-size: 40rpx;
		padding-right: 20rpx;
	}

	.fail {
		color: #CCC;
		font-size: 40rpx;
		padding-right: 20rpx;
	}

	.payment-status {
		background-color: #fff;
		margin: 195rpx 30rpx 0 30rpx;
		border-radius: 10rpx;
		padding: 1rpx 0 28rpx 0;
	}

	.payment-status .status {
		font-size: 32rpx;
		font-weight: bold;
		text-align: center;
		margin: 70rpx 0 70rpx 0;
		
		color: #333333;
	}

	.payment-status .wrapper {
		border: 1rpx solid #eee;
		margin: 0 30rpx 47rpx 30rpx;
		padding: 35rpx 0;
		border-left: 0;
		border-right: 0;
	}

	.payment-status .wrapper .item {
		font-size: 28rpx;
		color: #282828;
	}

	.payment-status .wrapper .item~.item {
		margin-top: 20rpx;
	}

	.payment-status .wrapper .item .itemCom {
		color: #666;
	}

	.payment-status .returnBnt {
		width: 630rpx;
		height: 86rpx;
		border-radius: 50rpx;
		color: #fff;
		font-size: 30rpx;
		text-align: center;
		line-height: 86rpx;
		margin: 0 auto 20rpx auto;

	}

	.cart-color {
		@include main_color(theme);
		@include coupons_border_color(theme);
	}
</style>